function Course_list() {
    var _this = this;
    var page;
    _this.obj = null;
    _this.templateArr = [];
    _this.page_size = 10;

    // init
    _this.init = function(_page) {
        page = _page;
        _this.initTable();
        _this.initEvent();
    };

    _this.initTable = function() {
        var trainRoleId = $("#roleId").val();
        var list_url = appPath + "/student/studySelf/showRoleCourseList?trainRoleId="+trainRoleId;
        page.init("select_course_form", list_url, "select_course_list", "select_course_page", 1, _this.page_size);
        page.goPage(1);
        page.list = function(dataList){
            _this.obj = dataList;
            if(dataList == null){
                return;
            }
            var len = dataList.length;
            var inner = "", item;
            // 组装数据
            for(var i=0; i< len; i++) {
                item = dataList[i];
                inner += '<tr >';
                inner += '<td width="50">' + (i+1) + '</td>';
                inner += '<td  width="100">'+ item['course_no'] + '</td>';
                inner += '<td ><span class="text-orange tooltip" data-length="15">'+ item['course_name'] + '</span></td>';
                /*inner += '<td width="80">'+ item['role_name'] + '</td>';*/
                inner += '<td width="80">'+ item['class_hour'] + '</td>';
                inner += '<td width="80">'+ item['question_count'] + '</td>';
                inner += '<td width="80">'+ TimeUtil.getHouAndMinAndSec(item['study_time'])+ '</td>';
                inner += '<td width="160"><a href="javascript:course_list.courseView(\''+ item['course_id'] +'\');" class="a a-info">学习</a> ';
                inner += '<a href="javascript:course_list.questionView(\''+ item['course_id'] +'\');" class="a a-publish">练习</a></td>';
                inner += '</tr>';
            }
            return inner;
        }

    };



    _this.initEvent = function () {
        //搜索
        $("#courseName_search").click(function () {
            _this.search();
        });

       //全部
        $("#course_all").click(function () {
            _this.all();
        });

       //课程预览
        $("#course_view").click(function () {
            _this.courseView();
        });
        //题库预览
        $("#question_view").click(function () {
            _this.questionView();
        });

        //全选
        $("#checkAll").click(function () {
            _this.courseCheckAll();
        });

    };

    //关闭对话框
    _this.closeDialog =function () {
        parent.layer.close(parent.layer.getFrameIndex(window.name));
    };
    //获取id索引
    _this.getIndex = function(obj, attr){
        var index = -1;
        $.each(obj,function(i, n){
            if( this.intId == attr ){
                index = i;
                return false;
            }
        });
        return index;
    };

    //搜索
    _this.search=function(){
      $("#courseName").val($.trim($("#courseName").val()));
        _this.initTable();
    };
    //全部
    _this.all = function() {
        $("#courseName").val("");
        _this.initTable();
    };
    //详情
    _this.info=function (courseId) {
        window.location.href=appPath+"/student/studySelf/viewCourseInfo?courseId="+courseId;

    };
    //课程预览
    _this.courseView=function (courseId) {
        var roleId = $("#roleId").val();
        common.goto_student_study(null,courseId,roleId,null);

    };
    //题库预览
    _this.questionView=function (courseId) {
        window.open(appPath + "/student/studySelf/exercise?course_id=" + courseId);

    };
    _this.ajax = function(url, param, type){
        var result;
        $.ajax({
            url: url,
            async: false,
            type: 'post',
            data: param,
            success: function(data){
                result = data.result;
            }
        });
        return result;
    };
}

var course_list = new Course_list();

bind_click = function(t){
    var value = $(t).attr("data-value");
    $("#roleId").val(value);
    course_list.initTable(page);
};
